<?php
class Controller_SpecialsMeetings extends Controller  {

	function __construct()
	{

		parent::__construct();
	}

	public function actionIndex(){
		$pk = $this->getPkName();
		$pkv =  _gp($pk,'int');
		$data = $this->be($pkv);


		$forums = M('SpecialsMeetingsForums')->getForumsByMid($pkv);



		$this->assign('data',$data);
		$this->assign('top_nav',$this->_parseNav($data['top_nav']));
		$this->assign('flash_news',$this->_parseFlashNews($data['flash_news']));
		$this->assign('forums',$forums);

		$this->display();
	}

	function actionNewsList(){
		$pk = $this->getPkName();
		$pkv =  _gp($pk,'int');
		$data = $this->be($pkv);
		$category = strip_tags(_gp('category','string'));
		$this->assign('data',$data);
		
		//$category = iconv('gbk','utf-8',$category);
		$this->assign('category',$category);
		$this->display("SpecialsNewsList");
	}
	
	private function _parseNav($string){

		$pk = $this->getPkName();
		$pkv =  _gp($pk,'int');
		
		$items = explode("\n",$string);
		foreach ($items as $item) {
			$tmp = explode("===", $item);
			$name = $tmp[0];
			$link = $tmp[1];
			$link .= strpos($link,'?')>-1 ? "&i=$pkv" : "?i=$pkv"; 
			$ret[$name] = $link;
		}
		return $ret;
	}

	private function _parseFlashNews($string){
		$data = unserialize($string);
		for ($i=0;$i<count($data['imgs']);$i++){
			$ret[$i]['_picture'] = M('UploadFiles')->getUrl($data['imgs'][$i]);
			$ret[$i]['url'] = $data['urls'][$i];
			$ret[$i]['subject'] = $data['titles'][$i];
		}
		return $ret;
	}
}
